{% extends 'layout/basic.html' %}
{% load static %}
{% block title %}用户注册{% endblock %}
{% block css %}

    <link rel="stylesheet" href="{% static 'css/account.css' %}">

{% endblock %}
{% block content %}

    <div class="container">
        {#        <h2>用户注册</h2>#}
        <div class="account">
            <div class="title">用户注册</div>
            <form id="form" method="POST" novalidate>
                {% csrf_token %}
                {% for field in form %}
                    {% if field.name == 'code' %}
                        <div class="form-group">
                            <label for="{{ field.id_for_label }}">{{ field.label }}</label>
                            <div class="row">
                                <div class="col-xs-7">
                                    {{ field }}
                                    <span class="error-msg">{{ field.errors.0 }}</span>
                                </div>
                                <div class="col-xs-5">
                                    <input id="smsBtn" type="button" class="btn btn-default" value="点击获取验证码">
                                </div>
                            </div>

                            <!--<input type="email" class="form-control" id="exampleInputEmail1" placeholder="Email">-->
                        </div>

                    {% else %}
                        <div class="form-group">
                            <label for="{{ field.id_for_label }}">{{ field.label }}</label>
                            <!--<input type="email" class="form-control" id="exampleInputEmail1" placeholder="Email">-->
                            {{ field }}
                            <span class="error-msg">{{ field.errors.0 }}</span>
                        </div>
                    {% endif %}
                {% endfor %}

                <div class="row">
                    <div class="col-xs-3">
                        <input type="button" class="btn btn-primary" value="注册"/>
                    </div>
                </div>
            </form>
        </div>


    </div>

{% endblock %}


{% block js %}

    <script>
        $(function () {
            bindClickBtnsms();
        })
        {#获取验证码函数#}
        function bindClickBtnsms() {
            $('#smsBtn').click(function () {
                var mobilePhone = $('#id_mobile_phone').val();
                $.ajax({
                    url:"/send/sms/",
                    type:'GET',
                    data:{ mobile_phone:mobilePhone,tpl:"register"},
                    success:function (res) {
                            console.log(res);

                    }

                })


            })


        }
    </script>

{% endblock %}